package com.zyh.flink.day02.source;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Collections;

public class FromCollectionTest {
    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment executionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();

        //从集合中加载数据转换为数据源
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7);

        DataStreamSource<Integer> dataStreamSource = executionEnvironment.fromCollection(list);
        SingleOutputStreamOperator<Integer> result = dataStreamSource.map(num -> num * 10).returns(Types.INT);
        //参数是添加前缀
        result.print("baizhi");
        executionEnvironment.execute("a");
    }
}
